<?php
/**
 * Lấy về danh sách các entry trong DB
 * @return type 
 */
function get_list_entry()
{
    $result = mysqli_query(getDB(), "SELECT EntryId, Title, DatePosted, Published, Username, `entries`.`UserId` 
                                    FROM entries, accounts
                                    WHERE `accounts`.`UserId` = `entries`.`UserId`");
    $list = array();
    if(mysqli_num_rows($result) > 0)
    {
        while($row = mysqli_fetch_assoc($result))
        {
            $list[] = $row;
        }
    }
    return $list;
}

/**
 *
 * @param type $id
 * @return type 
 */
function get_entry($id)
{
    $result = mysqli_query(getDB(), "SELECT * FROM entries WHERE IdEntries = '{$id}' LIMIT 1");
    if($result !== FALSE)
    {
        while($row = mysqli_fetch_assoc($result))
        {
            return $row;
        }
    }
}
?>
